﻿@{
    Layout = "~/Views/Shared/_Layout.cshtml";
}
@section styles{
    <style>
    </style>
}
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form" lay-filter="dictype-form" style="padding: 15px 0 0 0;">
            <input type="hidden" name="Id" value="@Model.Id" />
            <input type="hidden" name="Dictype" value="@Model.Dictype" />
            <div class="layui-form-item">
                <label class="layui-form-label layui-form-required">字典名称</label>
                <div class="layui-input-block">
                    <input type="text" name="Dname" lay-verify="required" placeholder="请输入字典名称" autocomplete="off" class="layui-input" value="@Model.Dname">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序</label>
                <div class="layui-input-block">
                    <input type="number" id="Dseq" name="Dseq" placeholder="请输入排序"
                           autocomplete="off" class="layui-input" value="@Model.Dseq" min="0" max="99" />
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label">启用</label>
                <div class="layui-input-block">
                    <input type="checkbox" name="isenable" lay-skin="switch" @(Model.Isenable ? "checked" : "")>

                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">
                    描述
                </label>
                <div class="layui-input-block">
                    <textarea name="remark" placeholder="请输入描述" class="layui-textarea">@Model.Remark</textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-hide" lay-submit lay-filter="dictype-submit" id="dictype-submit">提交</button>
                </div>
            </div>
        </form>
    </div></div>

    


        @section scripts{

            <script type="text/javascript">
                layui.use(['lscom', 'form'], function () {
                    var $ = layui.$;
                    var lscom = layui.lscom;
                    var form = layui.form;

                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.iframeAuto(index);

                    window.submitForm = function () {
                        $("#dictype-submit").click();
                    }

                    form.on('submit(dictype-submit)', function (data) {

                        data.field.isenable = data.field.isenable == "on";
                        var field = data.field;
                        var waitIndex = parent.layer.load(2);
                        lscom.ajax({
                            url: "/Systems/Dictionary/SaveDictionaryType",
                            data: JSON.stringify(field),
                            lsHandleError: false
                        }).done(function (data) {
                            if (data.code == 0) {
                                data.index = index;
                                let parentWindow = parent.selectedWindow().window;
                                parentWindow.saveTypeCallback(data);
                            }
                        }).fail(function (message) {
                            lscom.notify.error(message);
                        }).always(function () {
                            parent.layer.close(waitIndex);
                        });

                        return false;
                    });
                });
            </script>

        }

